{ int testInteger = 5;
printf("Number = %d", testInteger); return 0;
} Output:Number = 5
We use %d format specifier to print int types.
Here, the %d inside the quotations will be replaced by the value of testInteger
Example : float and double Output
#include <stdio.h>
int main()
{ float number1 = 13.5;
double number2 = 12.4;
printf("number1 = %f\n", number1);
printf("number2 = %lf", number2);
return 0; }
Output : number1 = 13.500000
number2 = 12.400000
To print float, we use %f format specifier. Similarly, we use %lf to print doublevalues.
Example 4: Print Characters
#include <stdio.h> int main()
{
char chr = 'a';
printf("character = %c.", chr);
return 0;
}
Output
character = a
To print char, we use %c format specifier.
Enumeration constants
Keyword enum is used to define enumeration data types
Enumeration is a user defined data type in C. It is mainly used to assign names to integral
constants
For example:
enum color {yellow, green, black, white};
Here, color is a variable and yellow, green, black and white are the enumeration constants having
value 0, 1, 2 and 3 respectively.
An example program to demonstrate working
// of enum in C
#include<stdio.h>
enumweek{Mon, Tue, Wed, Thur, Fri, Sat, Sun};
int main( )
{
enum week day;
day = Wed;
printf("%d",day);
return 0;